<?php
class BaseModel
{
	protected $pdo;
	
	public function __construct()
	{
		$this->pdo = new PDO("sqlite:" . DB_FILENAME, null, null, array(PDO::ATTR_PERSISTENT => true));	
        $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $this->pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
        $this->pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
	}
	
	protected function getUserIdOrZero() 
	{
		if(session_status() != PHP_SESSION_ACTIVE)
		{
			session_start();
		}
		
		if (isset($_SESSION["current_user"]))
		{
			return $_SESSION["current_user"];
		}
		else
		{
			return 0;
		}
	}
	
	
	
	protected function makeSafe($unsafe)
	{
		$safe = $unsafe;
		return $safe;
	}
}